package com.yuanian.ecsplus.bean.entity;

import com.yuanian.ecsplus.cache.CacheManager;
import com.yuanian.ecsplus.meta.entity.MetaEntity;
import com.yuanian.ecsplus.meta.vo.MetaVo;
import com.yuanian.ecsplus.model.entity.BaseModel;
import com.yuanian.ecsplus.platform.PlatformSupport;
import com.yuanian.ecsplus.platform.SpringContextBean;
import com.yuanian.ecsplus.session.FullDataSession;

import java.util.HashMap;
import java.util.Map;

public class SimpleDataModel<T extends BaseModel> implements FullDataSession<T> {

    //查询实体类字节
    private Class<T> clz;

    //平台的支撑类
    private PlatformSupport platformSupport;

    public SimpleDataModel(Class<T> clz) {
        this.clz = clz;
        this.platformSupport = SpringContextBean.getBean(PlatformSupport.class);
    }

    @Override
    public Map createMapOne() {
        return null;
    }

    @Override
    public Map createMapOne(Map initData) {
        return null;
    }

    @Override
    public T createOne(boolean insertFlag) {
        return createOne(new HashMap<>(), insertFlag);
    }

    @Override
    public T createOne(Map initData, boolean insertFlag) {
        MetaEntity<T> metaEntity = CacheManager.getInstance().getMetaEntity(clz);
        return metaEntity.findFieldList(initData, insertFlag);
    }

}
